# Maintainer: kpcyrd <git@rxv.cc>
pkgname=wasm-bindgen
pkgver=0.2.89
pkgrel=0
pkgdesc="Interoperating JS and Rust code"
url="https://github.com/rustwasm/wasm-bindgen"
arch="all"
license="Apache-2.0"
depends="cargo nodejs rust-wasm"
makedepends="
	cargo-auditable
	"
source="https://github.com/rustwasm/wasm-bindgen/archive/refs/tags/$pkgver/wasm-bindgen-$pkgver.tar.gz
	Cargo-$pkgver.lock::https://gitlab.archlinux.org/archlinux/packaging/packages/wasm-bindgen/-/raw/$pkgver-1/Cargo.lock
	"
options="net !check" # most tests fail outside of x86_64

prepare() {
	default_prepare

	# https://github.com/rustwasm/wasm-bindgen/issues/1819
	mv "$srcdir/Cargo-$pkgver.lock" Cargo.lock

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cd crates/cli
	cargo auditable build --release --frozen
}

check() {
	cd crates/cli
	cargo test --frozen
}

package() {
	install -Dm755 -t "$pkgdir"/usr/bin \
		target/release/wasm-bindgen \
		target/release/wasm-bindgen-test-runner \
		target/release/wasm2es6js
}

sha512sums="
391500fe905cdb158ba39fefd453186f31bc72af9b861e047c954f8e0c3000ed64509a8d6925fbd2a046da2a440fd8ce606db9ecdc1c57247d8e3c28a6f48de3  wasm-bindgen-0.2.89.tar.gz
ef27a4aa7cc2da459a56e5edb176bce973e7d39b2270806856707ac33f2f291621249fff3d5114112e5e9f89df42cdd4b7e298f087b22f762e2aa27130a83445  Cargo-0.2.89.lock
"
